package DataReading;

// Class containing all the main information about the ship
public class Vessel {

	// variables for class
	private int ID;
	private int type;
	private double xPosition;
	private double yPosition;
	private double xVelocity;
	private double yVelocity;
	private int startTime;
	private double speed;
	private double distance;
	private double updateTime;
	private String course; 
	private double initXP;
	private double initYP;
	
	// Default Constructor
	public Vessel()	{
		ID = 0000;
		type = 1;
		xPosition = 0;
		yPosition = 0;
		xVelocity = 0;
		yVelocity = 0;
	}
	
	// Parameterized Constructor
	public Vessel(int id, int t, double xP, double yP, double xV, double yV, int sT) {
		ID = id;
		type = t;
		xPosition = xP;
		yPosition = yP;
		xVelocity = xV;
		yVelocity = yV;
		startTime = sT;
		updateCourse();
		updateDistance();
		updateTime = 0;
		initXP = xPosition;
		initYP = yPosition;
	}
	
	// Mutators for the Class
	public void setID(int id) { this.ID = id; }
	public void seType(int t) { this.type = t; }
	public void setXPosition(double xp) { this.xPosition = xp; }
	public void setYPosition(double yp) { this.yPosition = yp; }
	public void setXVelocity(double xv) { this.xVelocity = xv; }
	public void setYVelocity(double yv) { this.yVelocity = yv; }
	public void setStartTime(int st) { this.startTime = st; }
	public void setSpeed(double spd) { this.speed = spd; }
	public void setCourse(String course) {	this.course = course;	}
	public void setDistance(double distance) {	this.distance = distance;	}
	public void setUpdateTime(double updateTime) {	this.updateTime = updateTime;	}

	// Accessors for the Class
	public int getID() { return this.ID; }
	public int getType() { return this.type; }
	public double getXPosition() { return this.xPosition; }
	public double getYPosition() { return this.yPosition; }
	public double getXVelocity() { return this.xVelocity; }
	public double getYVelocity() { return this.yVelocity; }
	public int getStartTime() { return this.startTime; }
	public double getSpeed() { return this.speed;}
	public double getDistance() { return distance; }
	public String getCourse() {	return course;	}	
	public double getUpdateTime() {	return updateTime;	}
	public double getInitXP() { return this.initXP; }
	public double getInitYP() { return this.initYP; }

	
	// Get the type name of the Vessel - If needed to display on GUI!
	public String getTypeName() {
		switch (this.type) {
			case 1:	return "Human (swimmer)";
			case 2: return "Speed Boat";
			case 3: return "Fishing Boat";
			case 4: return "Cargo Vessel";
			case 5: return "Passenger Vessel";
			default: return "Invalid Type";
		}	
	}
	
	public void updateCourse() {
		if (xPosition >=0) {
			if (yPosition >= 0) {
				course = "NE";
			}
			else course = "NW";
		}
		else {
			if (yPosition >= 0) {
				course = "SE";
			}
			else course = "SW";
		}
	}
	
	public void updateDistance() {
		double a = xPosition;
		double b = yPosition;
		a = a * a;
		b = b * b;
		distance = Math.sqrt(a + b);
	}
	
	public void timeUpdate(double currentTime) {
		updateTime = currentTime - startTime;
	}
	
}
